package com.study.studyroom.entity.bo;

import com.study.studyroom.entity.enums.RequestResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RequestResult<T>{

    private int code;
    private T data;

    private String msg;


    public static <T> RequestResult<T>  success(T data) {
        RequestResultEnum success = RequestResultEnum.SUCCESS;
        return new RequestResult<>(success.getCode(), data, success.getMsg());
    }

    public static <T> RequestResult<T>  fail(RequestResultEnum requestResultEnum) {
        return new RequestResult<>(requestResultEnum.getCode(), null, requestResultEnum.getMsg());
    }

}
